package com.ruoyi.web.controller.shop.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.member.MemberLabelDO;
import com.ruoyi.common.entity.VO.member.MemberLabelSearchVO;
import com.ruoyi.common.entity.VO.member.MemberLabelVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IBackShopMemberLabelMapper extends BaseMapper<MemberLabelDO> {

    List<MemberLabelVO> searchList(MemberLabelSearchVO searchVO);

    @Select("select a.member_label_id id,b.label_name labelName from member_label_link a left join member_label b on a.member_label_id=b.id where member_id=#{memberId}")
    List<MemberLabelVO> searchLinkList(@Param("memberId") Long memberId);

    @Select("select id from member_label where shop_id=#{shopId} and label_name=#{labelName}")
    MemberLabelDO checkLabelNameUnique(@Param("labelName") String labelName, @Param("shopId") Long shopId);

    @Select("select label_name from member_label where id=#{id}")
    String getLabelNameById(Long id);

    @Delete("delete from member_label_link where member_id=#{memberId}")
    int deleteByMemberId(Long memberId);

}
